package com.infocollect.framework.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component(value = "ossConfig")
@ConfigurationProperties(prefix = "oss-config", ignoreUnknownFields = false)
public class OSSConfig {

    private Long expireSignature;
    private Long expireFileUrl;
    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;
    private String bucket;
    private String urlPath;
    private String directory;
    private String gcloudFlag;
    private String tyCloudFlag;



    public Long getExpireSignature() {
        return expireSignature;
    }

    public void setExpireSignature(Long expireSignature) {
        this.expireSignature = expireSignature;
    }

    public Long getExpireFileUrl() {
        return expireFileUrl;
    }

    public void setExpireFileUrl(Long expireFileUrl) {
        this.expireFileUrl = expireFileUrl;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }

    public String getUrlPath() {
        return urlPath;
    }

    public void setUrlPath(String urlPath) {
        this.urlPath = urlPath;
    }

    public String getDirectory() {
        return directory;
    }

    public void setDirectory(String directory) {
        this.directory = directory;
    }

    public String getGcloudFlag() {
        return gcloudFlag;
    }

    public void setGcloudFlag(String gcloudFlag) {
        this.gcloudFlag = gcloudFlag;
    }

    public String getTyCloudFlag() {
        return tyCloudFlag;
    }

    public void setTyCloudFlag(String tyCloudFlag) {
        this.tyCloudFlag = tyCloudFlag;
    }

    /**
     * oss上传服务地址获取
     *
     * @return
     */
    public String getFileBucketDomain() {
        if("1".equals(tyCloudFlag))
        {
            return urlPath;
        }else {
            if ("1".equals(gcloudFlag)) {
                return urlPath;
            } else {
                String host = "http://" + this.getBucket() + "." + getEndpoint();
                return host;
            }
        }
    }
}